﻿using LiteBlog.Components;
using LiteBlog.Components.Contracts;
using LiteBlog.Components.Helpers;
using LiteBlog.Controllers;
using LiteBlog.Controllers.Contracts;
using LiteBlog.Controllers.Helpers;
using LiteBlog.Repositories.Helpers;
using LiteBlog.Repositories.Framework;
using LiteBlog.Repositories.Common;
using LiteBlog.Repositories.Contracts;
using LiteBlog.Repositories;
using StructureMap;
using StructureMap.Configuration.DSL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace LiteBlog.IoC
{
    // prefer explicit registration (auto-registration not good)
    class IoCRegistry : Registry
    {
        internal IoCRegistry()
            : base()
        {
            For<IXmlHelper>().Use<XmlHelper>();
            For<IDataContext>().Singleton().Use<DataContext>();

            For<DraftRepository>().Use<DraftRepository>();
            For<IArchiveRepository>().Use<ArchiveRepository>();
            For<IBlogRepository>().Use<BlogRepository>();
            For<BlogRepository>().Use<BlogRepository>(); // For StatData
            For<ICategoryRepository>().Use<CategoryRepository>();
            For<ICommentRepository>().Use<CommentRepository>();
            For<IPageRepository>().Use<PageRepository>();
            For<IPostRepository>().Use<PostRepository>();
            For<ISettingsRepository>().Use<SettingsRepository>();
            For<IStatRepository>().Use<StatRepository>().Setter<BlogRepository>().IsTheDefault();
            For<ITagRepository>().Use<TagRepository>();

            For<ICacheContext>().Use<CacheContext>();
            For<IConfigComp>().Use<ConfigComp>();
            For<ICacheComp>().Use<CacheComp>();
            For<IArchiveComp>().Use<ArchiveComp>();
            For<ArchiveComp>().Use<ArchiveComp>();
            For<IAuthorComp>().Use<AuthorComp>();
            For<AuthorComp>().Use<AuthorComp>();
            For<IBlogComp>().Use<BlogComp>();
            For<ICategoryComp>().Use<CategoryComp>();
            For<ICommentComp>().Use<CommentComp>();
            For<IPageComp>().Use<PageComp>();
            For<IPostComp>().Use<PostComp>();
            For<ISettingsComp>().Use<SettingsComp>();
            For<IBackupComp>().Use<BackupComp>();
            For<IStatComp>().Use<StatComp>();
            For<IFeedComp>().Use<FeedComp>();
            For<IDocumentComp>().Use<DocumentComp>();
            For<ISiteMapComp>().Use<SiteMapComp>();
            For<ITagComp>().Use<TagComp>();
            For<IAuthenticationHelper>().Use<AuthenticationHelper>();

            For<IAdminController>().Use<AdminController>();
            For<IArchiveController>().Use<ArchiveController>();
            For<IAuthorController>().Use<AuthorController>();
            For<ICategoryController>().Use<CategoryController>();
            For<ICommentController>().Use<CommentController>();
            For<IHomeController>().Use<HomeController>();
            For<IPageController>().Use<PageController>();
            For<IPostController>().Use<PostController>();
            For<ISkinController>().Use<SkinController>();
            For<IScheduleController>().Use<ScheduleController>();
            For<ISettingsController>().Use<SettingsController>();
            For<ITagController>().Use<TagController>();
        }
    }
}
